package com.xumz.ui;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.TextField;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import com.xumz.ui.listen.AnswerButtonActionListener;
import com.xumz.ui.listen.CheckButtonActionListener;
import com.xumz.ui.listen.MathButtonActionListener;

public class MathFactoryJframe extends JFrame {
	/**
	 * Version 1.0 2017098
	 */
	private static final long serialVersionUID = 2017098;
	public TextField field1;
	public TextField field2;
	public TextField field3;
	public TextField field5;
	public TextField field7;
	public TextField field8;

	public MathFactoryJframe() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//  关闭按钮的动作为
		// setSize(400, 300);//  设置窗口大小 
		setBounds(300, 200, 300, 300);// 位置 大小
		setResizable(false);// 设置不
		setVisible(true);//  设置窗口为可见的，默认为不
		initPanel();
	}

	private void initPanel() {
		Container container = this.getContentPane();
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		container.add(tabbedPane);

		JPanel panel1 = new JPanel(new BorderLayout());
		tabbedPane.addTab("生成题目与答案", panel1);
		JButton mathButton = new JButton("生成答案");
		panel1.add(mathButton);
		mathButton.setBounds(80, 140, 100, 20);
		JLabel jLabel1 = new JLabel("运算数范围：");
		field1 = new TextField();
		JLabel jLabel2 = new JLabel("运算符个数：");
		field2 = new TextField();
		JLabel jLabel3 = new JLabel("题目个数：");
		field3 = new TextField();
		JLabel jLabel4 = new JLabel("生成题目与答案文件:");
		jLabel1.setBounds(70, 20, 100, 20);
		field1.setBounds(150, 20, 50, 20);
		jLabel2.setBounds(70, 50, 100, 20);
		field2.setBounds(150, 50, 50, 20);
		jLabel3.setBounds(70, 80, 100, 20);
		field3.setBounds(150, 80, 50, 20);
		jLabel4.setBounds(70, 110, 100, 20);
		panel1.add(jLabel1);
		panel1.add(field1);
		panel1.add(jLabel2);
		panel1.add(field2);
		panel1.add(jLabel3);
		panel1.add(field3);
		panel1.add(jLabel4);

		JPanel panel2 = new JPanel(new BorderLayout());
		tabbedPane.addTab("生成答案", panel2);
		JButton answerButton = new JButton("生成答案");
		answerButton.setBounds(80, 140, 100, 20);
		panel2.add(answerButton);
		JLabel jLabel5 = new JLabel("题目文件地址:");
		field5 = new TextField();
		JLabel jLabel6 = new JLabel("解析题目，生成答案:");
		jLabel5.setBounds(0, 20, 100, 20);
		field5.setBounds(70, 50, 150, 20);
		jLabel6.setBounds(70, 110, 100, 20);
		panel2.add(jLabel5);
		panel2.add(field5);
		panel2.add(jLabel6);

		JPanel panel3 = new JPanel(new BorderLayout());
		tabbedPane.addTab("校验", panel3);
		JButton checkButton = new JButton("校验");
		checkButton.setBounds(80, 140, 100, 20);
		panel3.add(checkButton);
		JLabel jLabel7 = new JLabel("题目文件地址:");
		field7 = new TextField();
		JLabel jLabel8 = new JLabel("答案文件地址:");
		field8 = new TextField();
		JLabel jLabel9 = new JLabel("解析校验:");
		jLabel7.setBounds(0, 10, 100, 20);
		field7.setBounds(70, 40, 150, 20);
		jLabel8.setBounds(0, 70, 100, 20);
		field8.setBounds(70, 90, 150, 20);
		jLabel9.setBounds(0, 160, 100, 20);
		panel3.add(jLabel7);
		panel3.add(field7);
		panel3.add(jLabel8);
		panel3.add(field8);
		panel3.add(jLabel9);

		mathButton.addActionListener(new MathButtonActionListener(this));
		answerButton.addActionListener(new AnswerButtonActionListener(this));
		checkButton.addActionListener(new CheckButtonActionListener(this));
	}

	public static void main(String[] args) {
		new MathFactoryJframe();
	}
}
